#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(
   HINSTANCE hInstance,
   HINSTANCE hPrevInstance,
   //LPTSTR    lpCmdLine,          // WinCE
   LPSTR	lpCmdLine,
   int       nCmdShow )
{	
	WNDCLASS wc;
	HWND hWnd;
	MSG msg;
	//Register application main window class
	wc.style		= 0;
	wc.lpfnWndProc 	= MainWndProc;
	wc.cbClsExtra	= 0;
	wc.cbWndExtra	= 0;
	wc.hInstance 	= hInstance;
	wc.hIcon		= NULL;
	wc.hCursor 		= LoadCursor (NULL, IDC_ARROW);
	wc.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName	= NULL;
	wc.lpszClassName= "MyClass";
	
	if (RegisterClass(&wc) == 0) 
		return -1;
	
	// Create Main Window 
	hWnd = CreateWindowEx(WS_EX_DLGMODALFRAME, "MyClass","Hello",WS_VISIBLE | WS_CAPTION | WS_SYSMENU, \
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
	if (!IsWindow(hWnd))
		return -2;
	
	// Standard show and update calls
	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);
	
	// Application message loop
	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	
	return msg.wParam;
}

LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	RECT rect;
	HDC hdc;
	
	switch (wMsg)
	{
	case WM_PAINT:
			GetClientRect(hWnd, &rect);
			hdc = BeginPaint(hWnd, &ps);
			DrawText(hdc, "Hello Windows CE", -1, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
			EndPaint(hWnd, &ps);
			return 0;
case WM_DESTROY:
			PostQuitMessage (0);
			break;
	}
	return DefWindowProc (hWnd, wMsg, wParam, lParam);
}

